﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using Restaurant.DAO;
using Restaurant.DTO;
using System.Data;
using System.Data.SqlClient;

namespace Restaurant.BUS
{
    public class HoaDonService
    {
        private HoaDonDB hdDAO = new HoaDonDB();

        public DataTable LoadHoaDon()
        {
            return hdDAO.LoadHoaDon();
        }

        public DataTable LoadHoaDonTheoNgayNH(int MaNH, DateTime Ngay)
        {
            return hdDAO.LoadHoaDonTheoNgayNH(MaNH, Ngay);
        }

        public bool SuaHoaDon(HoaDon hd)
        {
            if (hdDAO.SuaHoaDon(hd.MaHDB,hd.MaKH,hd.MaNH,hd.NgayLapHD,hd.ThanhTien))
                return true;
            return false;
        }

        public bool XoaHoaDon(HoaDon hd)
        {
            if (hdDAO.XoaHoaDon(hd.MaHDB))
                return true;
            return false;
        }

        public bool ThemHoaDon(HoaDon hd)
        {
            if (hd.MaKH.ToString() == "" || hd.MaNH.ToString() == "" || hd.NgayLapHD.ToString() == "" || hd.ThanhTien.ToString() == "")
            {
                return false;
            }
            if (hdDAO.ThemHoaDon(hd.MaKH,hd.MaNH,hd.NgayLapHD,hd.ThanhTien))
                return true;
            return false;
        }
    }
}
